//
//  AppDelegate.m
//  VEW
//
//  Created by lanou3g on 15/7/17.
//  Copyright (c) 2015年 Y团. All rights reserved.
//

#import "AppDelegate.h"
#import "HomeTableViewController.h"
#import "QuickMesTableViewController.h"
#import "WorldTableViewController.h"
#import "HotChatTableViewController.h"
#import "LeftViewController.h"
#import "RightTableViewController.h"
//#import "RightTableViewController.h"

@interface AppDelegate ()<UITabBarControllerDelegate>

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    
    HomeTableViewController *homeTVC=[[HomeTableViewController alloc]initWithStyle:UITableViewStylePlain];
    self.homeNC=[[UINavigationController alloc]initWithRootViewController:homeTVC];
    
//    [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navigationbar.png"] forBarMetrics:UIBarMetricsDefault];
    
    
//    self.window.rootViewController = homeNC;
    
    
    _homeNC.tabBarItem.title=@"首页";
    
    //设置tabbar首页图片,在标签上设置图片是自己渲染上去的,如果让渲染的图片是原生的,就需要调用渲染模式这个方法;将渲染模式设置成原生图片;
    _homeNC.tabBarItem.image=[[UIImage imageNamed:@"首页.png"]imageWithRenderingMode:UIImageRenderingModeAutomatic];

    _homeNC.tabBarController.tabBar.translucent = false;
    QuickMesTableViewController *quickTVC=[[QuickMesTableViewController alloc]initWithStyle:UITableViewStylePlain];
    UINavigationController *quickNC=[[UINavigationController alloc]initWithRootViewController:quickTVC];
    quickNC.tabBarItem.title=@"快讯";
    quickNC.tabBarItem.image=[[UIImage imageNamed:@"快讯.png"]imageWithRenderingMode:UIImageRenderingModeAutomatic];
    
    WorldTableViewController *worldTVC=[[WorldTableViewController alloc]initWithStyle:UITableViewStylePlain];
    UINavigationController *worldNC=[[UINavigationController alloc]initWithRootViewController:worldTVC];
    worldNC.tabBarItem.title=@"世界";
    worldNC.tabBarItem.image=[[UIImage imageNamed:@"世界.png"]imageWithRenderingMode:UIImageRenderingModeAutomatic];
    
    HotChatTableViewController *hotTVC=[[HotChatTableViewController alloc]initWithStyle:UITableViewStylePlain];
    UINavigationController *hotNC=[[UINavigationController alloc]initWithRootViewController:hotTVC];
    hotNC.tabBarItem.title=@"热评";
    hotNC.tabBarItem.image=[[UIImage imageNamed:@"热评"]imageWithRenderingMode:UIImageRenderingModeAutomatic];
    
    //创建一个标签视图控制器对象
    UITabBarController *tabBC=[[UITabBarController alloc]init];
    //被标签视图控制器管理的所有的控制器都放在viewcontrollers里面
    tabBC.viewControllers=@[_homeNC,quickNC,worldNC,hotNC];
    //设置代理
    tabBC.delegate=self;
    //修改的是标签栏上item的颜色
    tabBC.tabBar.tintColor=[UIColor blackColor];
    //设置标签栏的背景图片
    tabBC.tabBar.backgroundImage=[UIImage imageNamed:@""];
    //设置第几个控制器被选中;如果不设置,默认为数组的第0位;
    tabBC.selectedIndex=0;
    
     self.window.rootViewController=tabBC;
    
    LeftViewController *leftVC=[[LeftViewController alloc]init];

    
    self.LeftSlideVC = [[LeftSlideViewController alloc]initWithLeftView:leftVC andMainView:tabBC];
    
    self.window.rootViewController = self.LeftSlideVC;
    
    
//     [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"上.jpg"] forBarMetrics:UIBarMetricsDefault];
    
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
